package com.fanxuankai.boot.canal.client.autoconfigure;

import com.alibaba.otter.canal.protocol.CanalEntry;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;

/**
 * @author fanxuankai
 */
public class MergeEntry {
    /**
     * 是否合并
     */
    private Boolean merge;

    /**
     * 合并后的最大数据行数量
     * key: EventType value: 数量
     */
    private Map<CanalEntry.EventType, Integer> maxRowDataSize = Collections.emptyMap();

    public Boolean getMerge() {
        return merge;
    }

    public void setMerge(Boolean merge) {
        this.merge = merge;
    }

    public Map<CanalEntry.EventType, Integer> getMaxRowDataSize() {
        return maxRowDataSize;
    }

    public void setMaxRowDataSize(Map<CanalEntry.EventType, Integer> maxRowDataSize) {
        this.maxRowDataSize = maxRowDataSize;
    }

    public int getMaxRowDataSize(CanalEntry.EventType eventType) {
        return Optional.ofNullable(maxRowDataSize.get(eventType)).orElse(1000);
    }
}